<?php
/**
 *
 * @group_name
 *
 * @author Master
 *
 * @api UpdataUserInfo
 *
 * @time 2020/6/5 - 0:49
 *
 */

namespace app\api\validate;
use think\Db;
use think\Validate;

class UpdataUserInfo extends Validate{
    protected $rule = [
        'id' =>'require',
        'sex' => 'require|check_sex:sex',
        'age' => 'require',
        'address' => 'require',
    ];

    protected $message = [
        'sex.require' => '性别不能为空',
        'id.require' => '用户编号不能为空',
        'age.require' => '年龄不能为空',
        'address.require' => '地址不能为空',
    ];

    public function check_sex($data){
        switch ($data){
            case '男':
                return true;
                break;
            case '女':
                return true;
                break;
            default:
                return "性别仅限输入男和女";
                break;
        }
    }
}